module.exports = {
  tendencyDuoBuySellNormal () {
    const dayEmaInfo = this.btbItem.dayEmaInfo || {}
    const hourEmaInfo = this.btbItem.hourEmaInfo || {}
    const hour4EmaInfo = this.btbItem.hour4EmaInfo || {}
    const minute15EmaInfo = this.btbItem.minute15EmaInfo || {}
    // if (dayEmaInfo.isLongDuo && this.btbIndexTotalInfo.positionFen > 50) {
    //   if (
    //     (dayEmaInfo.isKdjIncrease || dayEmaInfo.isMacdIncrease) &&
    //     hourEmaInfo.isDuo && minute15EmaInfo.isDuo
    //   ) {
    //     this.setBuy('tendencyDuoBuySellNormal-1')
    //   }
    // } else {
    //
    // }
    // 按小时线做多
    if (
      (hourEmaInfo.ema10 > hourEmaInfo.ema20 && hourEmaInfo.ema5 > hourEmaInfo.ema20) &&
      (hourEmaInfo.isKdjIncrease || hourEmaInfo.isMacdIncrease) &&
      (hourEmaInfo.macd > 0 || hourEmaInfo.kdjDiff > 0)
    ) {
      if (
        hourEmaInfo.isKdjIncrease && hourEmaInfo.isMacdIncrease &&
        minute15EmaInfo.kdjDiff > 0 &&
        minute15EmaInfo.isDuo &&
        (minute15EmaInfo.isKdjIncrease && minute15EmaInfo.isMacdIncrease) &&
        !dayEmaInfo.isKong &&
        !(hour4EmaInfo.isLongKong && dayEmaInfo.ema5 < dayEmaInfo.ema10 && dayEmaInfo.macd < 0)
      ) {
        this.setBuy('tendencyDuoBuySellNormal-2')
      }
    } else if (
      (dayEmaInfo.isKdjIncrease && dayEmaInfo.isMacdIncrease) &&
      hour4EmaInfo.isLongDuo &&
      (hour4EmaInfo.isKdjIncrease || hour4EmaInfo.isMacdIncrease) &&
      hourEmaInfo.isLongDuo
    ) {
      if (
        !dayEmaInfo.isKong &&
        (hourEmaInfo.isKdjIncrease && hourEmaInfo.isMacdIncrease) &&
        minute15EmaInfo.kdjDiff > 0 &&
        minute15EmaInfo.isDuo &&
        (minute15EmaInfo.isKdjIncrease && minute15EmaInfo.isMacdIncrease)
      ) {
        this.setBuy('tendencyDuoBuySellNormal-3')
      }
    } else {
      if (
        minute15EmaInfo.kdjDiff < 0 &&
        (minute15EmaInfo.macd < 0 || minute15EmaInfo.ema5 < minute15EmaInfo.ema10)
      ) {
        // 按天持有太能亏了
        this.setPingDuo('tendencyDuoBuySellNormal-101')
      }
    }
    // 不做空
    this.sell = false
    this.sellReason = ''
    if (this.hasKongPosition) {
      this.setPingKong('tendencyDuoBuySellNormal-201')
    }
  },
  weekDuoBuySellNormal () {
    const {
      isHourAndHour4SgOK
    } = this.indexFlagInfo
    const dayEmaInfo = this.btbItem.dayEmaInfo || {}
    const hour4EmaInfo = this.btbItem.hour4EmaInfo || {}
    const hourEmaInfo = this.btbItem.hourEmaInfo || {}
    const minute15EmaInfo = this.btbItem.minute15EmaInfo || {}
    if (
      (dayEmaInfo.isKdjDecline && dayEmaInfo.isMacdDecline) &&
      (hour4EmaInfo.isKdjDecline && hour4EmaInfo.isMacdDecline) &&
      hourEmaInfo.isLongKong &&
      (hourEmaInfo.isKdjDecline || hourEmaInfo.isMacdDecline)
    ) {
      if (hourEmaInfo.isKdjDecline && hourEmaInfo.isMacdDecline) {
        if (
          minute15EmaInfo.kdjDiff < 0 &&
          isHourAndHour4SgOK && minute15EmaInfo.sg > 0.8 &&
          minute15EmaInfo.isKong &&
          (minute15EmaInfo.isKdjDecline && minute15EmaInfo.isMacdDecline)
        ) {
          this.setSell('weekDuoBuySellNormal-1')
        }
      }
      if (minute15EmaInfo.kdjDiff < 0 && (minute15EmaInfo.macd < 0 || minute15EmaInfo.ema5 < minute15EmaInfo.ema10)) {
        this.setPingDuo('weekDuoBuySellNormal-101')
      }
    } else {
      if (this.hasKongPosition) {
        this.setPingKong('weekDuoBuySellNormal-201')
      }
      if (
        (dayEmaInfo.isLongDuo && hour4EmaInfo.isLongDuo) &&
        (hourEmaInfo.isLongDuo && (hourEmaInfo.isKdjIncrease || hourEmaInfo.isMacdIncrease))
      ) {
        if (
          !dayEmaInfo.isKong &&
          (hourEmaInfo.isKdjIncrease && hourEmaInfo.isMacdIncrease) &&
          (minute15EmaInfo.kdjDiff > 0 && minute15EmaInfo.sg > 0.8) &&
          minute15EmaInfo.isDuo &&
          (minute15EmaInfo.isKdjIncrease && minute15EmaInfo.isMacdIncrease)
        ) {
          this.setBuy('weekDuoBuySellNormal-2')
        }
      } else if (
        (dayEmaInfo.isDuo && hour4EmaInfo.isDuo) &&
        (hourEmaInfo.isLongDuo && (hourEmaInfo.isKdjIncrease || hourEmaInfo.isMacdIncrease))
      ) {
        if (
          !dayEmaInfo.isKong &&
          (hourEmaInfo.isKdjIncrease && hourEmaInfo.isMacdIncrease) &&
          (minute15EmaInfo.kdjDiff > 0 && minute15EmaInfo.sg > 0.8) &&
          minute15EmaInfo.isDuo &&
          (minute15EmaInfo.isKdjIncrease && minute15EmaInfo.isMacdIncrease)
        ) {
          this.setBuy('weekDuoBuySellNormal-3')
        }
      } else if (
        (dayEmaInfo.ema5 > dayEmaInfo.ema10 && dayEmaInfo.macd > 0 && dayEmaInfo.kdjDiff > 0 && dayEmaInfo.isAllIncrease) &&
        (hour4EmaInfo.isDuo && hour4EmaInfo.isAllIncrease && hour4EmaInfo.days5RealWave > 0.2 && hour4EmaInfo.days5MaxWave > 0.2) &&
        (hourEmaInfo.isDuo && hourEmaInfo.isAllIncrease && hourEmaInfo.macdud > 1)
      ) {
        if (
          minute15EmaInfo.isAllIncrease && minute15EmaInfo.isDuo
        ) {
          this.setBuy('weekDuoBuySellNormal-4')
        }
      } else {
        if (minute15EmaInfo.kdjDiff < 0 && (minute15EmaInfo.macd < 0 || minute15EmaInfo.ema5 < minute15EmaInfo.ema10)) {
          this.setPingDuo('weekDuoBuySellNormal-102')
        }
      }
    }
  }
}
